#include <iostream>
#include <unistd.h>
#include <signal.h>
using namespace std;

void handler(int signo)
{
    cout << "handler " << signo << endl;
} 

int main()
{
    cout << "getpid: " << getpid() << endl;
    signal(2, handler);
    sigset_t block, oblock;
    sigemptyset(&block);
    sigemptyset(&oblock);
    sigaddset(&block, 2); //将2号信号添加到自己定义的block信号集中
    sigprocmask(SIG_BLOCK, &block, &block);
    while(true)
    {
        sleep(1);
    }
    return 0;
}